package cn.numeron.wxarticle.impl.other

import androidx.navigation.NavAction
import androidx.navigation.NavGraph
import androidx.navigation.NavInflater
import androidx.navigation.navOptions
import cn.numeron.discovery.Implementation
import cn.numeron.common.frame.GraphRegistrar
import cn.numeron.wxarticle.impl.R

@Implementation
class WxArticleGraphRegistrar : GraphRegistrar {

    /** 把本模块的导航资源添加到主导航图中 */
    override fun register(mainGraph: NavGraph, navInflater: NavInflater) {
        val accountGraph = mainGraph.findNode(R.id.nav_wx_article)
        if (accountGraph == null) {
            val navGraph = navInflater.inflate(R.navigation.nav_wx_article)
            mainGraph.addDestination(navGraph)
            mainGraph.putAction(
                R.id.action_to_wx_article_graph,
                NavAction(R.id.nav_wx_article, navOptions {
                    anim {
                        enter = R.anim.translation_right_to_left_in
                        exit = R.anim.translation_right_to_left_out
                        popEnter = R.anim.translation_left_to_right_in
                        popExit = R.anim.translation_left_to_right_out
                    }
                })
            )
        }
    }

}